/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author admin
 */
@Entity
@Table(name = "role_film")
@NamedQueries({
	@NamedQuery(name = "RoleFilm.findAll", query = "SELECT r FROM RoleFilm r")})
public class RoleFilm implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_role")
	private Integer idRole;
	@Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "type")
	private String type;
	@JoinColumn(name = "id_person", referencedColumnName = "id_person")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
	private Person idPerson;
	@JoinColumn(name = "id_film", referencedColumnName = "id_film")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
	private Film idFilm;

	public RoleFilm() {
	}

	public RoleFilm(Integer idRole) {
		this.idRole = idRole;
	}

	public RoleFilm(Integer idRole, String type) {
		this.idRole = idRole;
		this.type = type;
	}

	public Integer getIdRole() {
		return idRole;
	}

	public void setIdRole(Integer idRole) {
		this.idRole = idRole;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Person getIdPerson() {
		return idPerson;
	}

	public void setIdPerson(Person idPerson) {
		this.idPerson = idPerson;
	}

	public Film getIdFilm() {
		return idFilm;
	}

	public void setIdFilm(Film idFilm) {
		this.idFilm = idFilm;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (idRole != null ? idRole.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof RoleFilm)) {
			return false;
		}
		RoleFilm other = (RoleFilm) object;
		if ((this.idRole == null && other.idRole != null) || (this.idRole != null && !this.idRole.equals(other.idRole))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "movie.entity.RoleFilm[ idRole=" + idRole + " ]";
	}
	
}
